package com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice.vo.DepRoomDevicePriceVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice.vo.RoomDevicePriceAssociationVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.nonIntelligentDevice.vo.RoomDevicePriceVO;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.roomdevice.vo.DepRoomVO;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomDevicePrice;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomDevicePriceAssociationService;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomDevicePriceService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "非智能设备设置价格")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiConstants.NAME + "/nonIntelligentDevice")
public class NonIntelligentDeviceController {

    private final IRoomDevicePriceService roomDevicePriceService;

    private final IRoomDevicePriceAssociationService roomDevicePriceAssociationService;

    /**
     * 手抄表水电费价格设置
     * @param roomDevicePriceVO
     * @return
     */
     @PostMapping("/add/priceConfig")
      public CommonResult<String> addConfig(@RequestBody RoomDevicePriceVO roomDevicePriceVO){
         return roomDevicePriceService.addConfig(roomDevicePriceVO);
     }

    /**
     * 修改手抄表水电费价格设置
     * @param roomDevicePriceVO
     * @return
     */
     @PostMapping("/update/priceConfig")
     public CommonResult<String> updateConfig(@RequestBody RoomDevicePriceVO roomDevicePriceVO){
         return roomDevicePriceService.updateConfig(roomDevicePriceVO);
     }

    /**
     * 分页查询非智能设备价格列表
     * @param pageSize
     * @param pageNum
     * @return
     */
     @GetMapping("/get/config")
     @Parameters({
             @Parameter(name = "pageSize", description = "每页大小"),
             @Parameter(name = "pageNum", description = "第几页")})
     public CommonResult<PageResult<RoomDevicePriceVO>> configPageList(Integer pageSize, Integer pageNum){
         return roomDevicePriceService.findAll(pageSize,pageNum);
    }

    /**
     * 将设置好的价格应用到房间
     * @param roomDevicePriceAssociationVO
     * @return
     */
    @PostMapping("/priceToRoom")
     public CommonResult<String> setPriceToRoom(@RequestBody RoomDevicePriceAssociationVO roomDevicePriceAssociationVO){
        return roomDevicePriceAssociationService.setPriceToRoom(roomDevicePriceAssociationVO);
     }

    /**
     * 删除已设置好的单价
     * @param devicePriceId
     * @return
     */
     @GetMapping("/delete/priceConfig")
     public CommonResult<String> deleteConfig(@Parameter Long devicePriceId){
        return roomDevicePriceService.deleteConfig(devicePriceId);
     }

    /**
     * 回显已应用到该单价对应的部门和房间
     * @param devicePriceId
     * @return
     */
     @GetMapping("find/depId/roomId")
     public CommonResult<List<DepRoomDevicePriceVO>> findAllRoomId(@Parameter long devicePriceId){

         return roomDevicePriceAssociationService.findAllRoomId(devicePriceId);

     }




}
